
package fileby.ctrl.actions.impl;

import fileby.core.ActionKey;
import fileby.model.IFileManager;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.JTextField;
import javax.swing.KeyStroke;

/**
 *
 * @author Jacob
 */
class SearchAction extends AbstractAction {

    private IFileManager fileManager;

    public SearchAction(IFileManager fileManager) {
        super();
        this.fileManager = fileManager;
        putValue(SHORT_DESCRIPTION, "Search for files");
        putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
    }

    public void actionPerformed(ActionEvent e) {
        JTextField t = (JTextField)this.getValue(ActionKey.SEARCH.toString());
        fileManager.search(t.getText());       
    }

}
